const service = require('../../../utils/service.js');
const api = require('../../../utils/util.js');
Page({
    data: {
        wayIndex: -1,
    	account_name: '',    //--真实姓名
    	account_number: '',  //--账户
    	bank: '',
    	money: 0       
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
    	this.setData({
    		money: options.money
    	});
    },
	//--提交提现
	submitWithdraw: function(et){
		let self = this;
		this.setData({
			account_name: et.detail.value.accountName || '',
			account_number: et.detail.value.accountNumber.replace(/\s+/g,"") || '',
			bank: et.detail.value.accountBank.replace(/\s+/g,"") || ''
		});
		if(this.data.account_name == ''){
			api.toast("请输入姓名！");
			return;
		}
		if(this.data.account_number == ''){
			$app.toast('请输入卡号');
			return;
		}
		if(!/^[0-9]{11,24}$/g.test(this.data.account_number)){
			api.toast('请输入合法的卡号！');
			return;
		}
		if(this.data.bank == '' || this.data.bank.length > 18){
			api.toast('请输入正确银行！');
			return;
		}
		api.ajax(service.url('buyWithdrawApply'),{
			type: 3,
			account: self.data.account_number,
			realname: self.data.account_name,
			bank: self.data.bank
		},function (res) {
			console.log("buy_withdraw_apply： "+JSON.stringify(res));
			if(res.code == 0){
				api.toast("提现申请成功！");
				setTimeout(function(){
					wx.navigateBack({
						delta: 2
					});
				},500);
			}
		});
	},
	bankCardNumber: function(){
		
	}
})
